package com.yunxin.admin.system.infra.persistence.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunxin.admin.system.domain.model.role.RoleMenuRepository;
import com.yunxin.admin.system.infra.persistence.entity.SysRoleMenuDO;
import com.yunxin.admin.system.infra.persistence.mapper.SysRoleMenuMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zero°
 * @since 2023-07-11
 */
@Repository
public class RoleMenuRepositoryImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenuDO> implements RoleMenuRepository, IService<SysRoleMenuDO> {

    @Override
    public List<Long> listMenuIdsByRoleId(Long roleId) {
        return this.baseMapper.listMenuIdsByRoleId(roleId);
    }

    @Override
    public boolean remove(Long roleId) {
        return this.remove(new LambdaQueryWrapper<SysRoleMenuDO>().eq(SysRoleMenuDO::getRoleId, roleId));
    }

    @Override
    public boolean saveBatch(Long roleId, List<Long> menuIds) {
//        List<SysRoleMenuDO> roleMenus = menuIds.stream()
//                .map(menuId -> new SysRoleMenuDO(roleId, menuId))
//                .toList();
//        return this.saveBatch(roleMenus);
//    }
        return true;}
}
